<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>使用对象字面量</title>
</head>
<body>
<script>
    function createPerson(firstName, lastName) {
        return {
            firstName: firstName,
            lastName: lastName,
            getFullName: function () {
                return this.firstName + ' ' + this.lastName;
            },
            greet: function (person) {
                alert('Hello, ' + person.getFullName() + ', I\'m ' + this.getFullName());
            }
        }
    }

    var johnDoe = createPerson('John', 'Doe');
    var janeDoe = createPerson('Jane', 'Doe');

    johnDoe.greet(janeDoe);
</script>
</body>
</html>